use ::function_name::named;

pub fn debug_demo() {
  test1();
  test2();
  test3();
  test1::test4();
  test5();
  test6();
  test2::test7();
}

fn test1() {
  let current_line = line!();
  println!("defined on line: {}", current_line);
  let current_col = column!();
  println!("defined on column: {}", current_col);
  let this_file = file!();
  println!("defined in file: {}", this_file);
}

fn test2() {
  let one_plus_one = stringify!(1 + 1);
  println!("{}", one_plus_one);
  assert_eq!(one_plus_one, "1 + 1");

  let v2 = stringify!("more than one");
  println!("{}", v2);
}

fn test3() {
  //真是太实用了
  let my_str = include_str!("main.rs");
  print!("{}", my_str);
}

mod test1 {
  pub fn test4() {
    println!("{}", module_path!());
  }
}

fn type_name_of<T>(_: T) -> &'static str {
  return std::any::type_name::<T>();
}

fn test5() {
  let str_value = "hello world";
  let string_value = String::from("hello world");
  println!("{}", type_name_of(string_value));
  println!("{}", type_name_of(str_value));
  println!("{}", std::any::type_name_of_val(&str_value));
  println!("{}", std::any::type_name_of_val(str_value));
}

#[named]
fn test6() {
  println!("{}", function_name!());
}

pub mod test2 {
  use ::function_name::named;
  #[named]
  pub fn test7() {
    println!("{}", function_name!());
  }
}

fn test8() {
  // println!("{}", item_path!());
}